home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 5_9.lha / 5_9 / 5_9c3.c < prev    next >
Text File  |  1993-08-08  |  518b  |  28 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. ain(int argc, char *argv[])
  6.  
  7.    srand(1);            // DELETE
  8.    if (argc != 3)
  9. error("two arguments expected");
  10.  
  11.    int count = 0;
  12.    int m = atoi(argv[1]);    // number of set members
  13.    int n = atoi(argv[2]);    // in the range 1..n
  14.    intset s(m,n);
  15.  
  16.    while (count < m)
  17. {
  18. int t = randint(n);
  19. if (s.member(t) == 0)
  20.     {
  21.     s.insert(t);
  22.     count++;
  23.     }
  24. }
  25.  
  26.    print_in_order(&s);
  27.  
  28.